home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / DATATURE / WAMPUM42.LZH / WAMPDOC.EXE / lha / WAMPUM / README1.DOC < prev    next >
Text File  |  1990-08-18  |  10KB  |  252 lines

  1. This application demonstrates how to develop a multi-relational data
  2. base system for order processing.  Look up CUSTOMER info from one file &
  3. part numbers as well as costs and descriptions from a separate PART file.
  4. WAMPUM automatically enters today's date as the ORDERDT as well as a
  5. unique ORDERNO.  WAMPUM also computes the total price of the order.
  6.  
  7. To start the application, do the following:
  8.  
  9.  1.  Add \WAMPUM to your DOS PATH by typing:  PATH=\WAMPUM
  10.  
  11.  2.  Set up the CLIPPER environment by typing:  SET CLIPPER=V010
  12.  
  13.  3.  Change to the sample application directory:  CD \WAMPUM\SAMPLE1
  14.  
  15.  4.  Run the WAMPUM program by typing:  WAMPUM VOODOO
  16.  
  17.  
  18. Here is the structure of the ORDERS file which permits customers to
  19. order up to three items in any quantity up to 99.
  20.  
  21. NUM  FLD NAME      TYPE      FLD LEN     FLD DEC
  22. ---  ----------    ----     ---------    -------
  23.   1  CUSTOMER       C           20          0
  24.   2  ADDRESS        C           30          0
  25.   3  CITY           C           15          0
  26.   4  STATE          C           15          0
  27.   5  ZIP            C           10          0
  28.   6  ORDERDT        D            8          0
  29.   7  PARTNO_1       C           10          0
  30.   8  DESCRIP_1      C           10          0
  31.   9  PRICE_1        N           10          2
  32.  10  QUAN_1         N            2          0
  33.  11  PARTNO_2       C           10          0
  34.  12  DESCRIP_2      C           10          0
  35.  13  PRICE_2        N           10          2
  36.  14  QUAN_2         N            2          0
  37.  15  PARTNO_3       C           10          0
  38.  16  DESCRIP_3      C           10          0
  39.  17  PRICE_3        N           10          2
  40.  18  QUAN_3         N            2          0
  41.  19  ORDER_TOT      N           11          2
  42.  20  ORDERNO        N            5          0
  43.   When a new order is placed by choosing A - Add a Record, a blank data
  44. entry screen appears.  Rather than having to type a customer name over
  45. and over as new orders are placed, these are entered in a separate
  46. customer file.  To call up the name and address of an existing
  47. customer, simply press ALT-9 while in ADD MODE.  If you want to see the
  48. whole table of customers alphabetically, press <ENTER> when prompted
  49. for the customer to find.  Then highlight the desired customer and
  50. press <ENTER>.  WAMPUM will automatically inserts the customer info.
  51.  
  52. To order a part, we will use the same sort of approach.  Rather than
  53. entering the name of the part, part number, and price, we will simply
  54. look them up from an existing PART table (another dBASE data base!).
  55. For the first part, press ALT-1 and then <ENTER> if you don't know the
  56. part name.  Highlight the desired part and press <ENTER>.  WAMPUM will
  57. insert the part information into fields 7, 8, and 9.  You will have to
  58. fill in the quantity.  ALT-2 and ALT-3 do this for two more part orders.
  59.  
  60. Automatically calculate the order date as TODAY (if you left this field
  61. blank) and WAMPUM will assign this order a UNIQUE order number, too.
  62.  
  63. All this magic is contained in two files.  Error checking and field
  64. calculations including the unique order number are entered into the
  65. EDIT.DBF file.  Table lookup is set up in the TABLE.DBF file.
  66.  
  67. An explanation of the various entries in the EDIT and TABLE files
  68. follows.
  69.  
  70.  
  71.  
  72.                        Edit Checks File Examples
  73.  
  74.  
  75. Record No. 1      *** WAMPUM BEGINNERS ALWAYS FORGET TO DO THIS! ***
  76.  
  77. EDITTEST: ORDERS
  78.  
  79. ERRMSG:
  80.  
  81. Comments:  The first record must contain the UPPER CASE name of the
  82. data base which will be used in conjunction with the EDIT.DBF file.
  83.  
  84.  
  85.  
  86. Record No.      2
  87.  
  88. EDITTEST: empty(flddata[1])
  89.  
  90. ERRMSG: Customer name is a required entry.
  91.  
  92. Comments:  The EDITTEST field defines an error condition.  In this
  93. case, we are checking for a blank FIRST field which is the CUSTOMER
  94. field.  If this error condition exists in either ADD or EDIT mode, the
  95. ERRMSG typed above will be displayed.  This prevents entry of a blank
  96. record.
  97.  
  98. Record No.      3
  99.  
  100. EDITTEST: =empty(flddata[6]) .and. helpcode=1
  101.  
  102. ERRMSG: 6,date()
  103.  
  104. Comments:  Here we are computing the order date if it is blank in ADD
  105. mode only.  HELPCODE=1 means the user chose option 1 from the WAMPUM
  106. Main Menu.  Empty(FLDDATA[6]) means the order date field is blank on
  107. the data entry screen.  Refer to the CREATING CALCULATED FIELDS
  108. section of the User's Guide for info on the ERRMSG entries.  In short,
  109. the 6 says compute the value for FLDDATA[6] and the computed value is
  110. DATE() which in dBASE lingo is TODAY.
  111.  
  112.  
  113. Record No.      4
  114.  
  115. EDITTEST: flddata[6]>date()
  116.  
  117. ERRMSG: Order date in the future is not permitted.
  118.  
  119. Comments:  Here we are making sure that the order date is NOT in the
  120. future.  Note that we are defining WHEN an error occurs, in short when
  121. the FLDDATA[6] field is GREATER THAN today's date.  If the error
  122. occurs, then the ERRMSG entered above will be displayed.
  123.  
  124.  
  125. Record No.      5
  126.  
  127. EDITTEST: EMPTY(FLDDATA[10]) .AND. .NOT. EMPTY(FLDDATA[7])
  128.  
  129. ERRMSG: Quantity for Part 1 cannot be 0.
  130.  
  131. Comments:  We want to make sure that if a PART NUMBER is entered for
  132. ITEM 1, that a quantity ordered is also entered.
  133.  
  134.  
  135.  
  136. Record No.      6
  137.  
  138. EDITTEST: !!.NOT. EMPTY(FLDDATA[10]) .and. helpcode=1
  139.  
  140. ERRMSG: 7,PART,PARTNO,ONHAND,ONHAND-FLDDATA[10]
  141.  
  142. Comments:  One of WAMPUM's major enhancements is demonstrated here. We
  143. are changing the value of the ONHAND count in a related data base when
  144. the user places a new order (ADD mode) and the ITEM 1 quantity is
  145. greater than 0.  In English, the ERRMSG means the following: open the
  146. PART data base with the PARTNO index.  Look up the PARTNO contained in
  147. FLDDATA[7].  Then decrement the existing ONHAND count by the amount
  148. contained in FLDDATA[10].  The same logic is used for PARTS 2 and 3.
  149.  
  150.  
  151. Record No. 11 simply tallies the TOTAL ORDER PRICE.
  152.  
  153. EDITTEST: =.T.
  154.  
  155. ERRMSG: 19,FLDDATA[18]*FLDDATA[17]+FLDDATA[14]*FLDDATA[13] . . .
  156. Record No. 12 demonstrates looking up a unique order number.  WAMPUM
  157. will automatically increment the UNIQUE number in UNIQUE.DBF and stuff
  158. the result in FLDDATA[20], the order number field, in ADD mode only.
  159.  
  160. EDITTEST: #HELPCODE=1 .and. empty(FLDDATA[20])
  161.  
  162.  
  163. ERRMSG: 20,UNIQUE
  164.  
  165.  
  166.  
  167.                          Table Lookup Examples
  168.  
  169.  
  170. Record No.      1
  171.  
  172. FILE: PART                  INDEX: PART
  173.  
  174. PROMPT Enter part name or <ENTER> for all:       DISPLAY1 PART
  175.  
  176. DISPLAY2 PARTNO      DISPLAY3 ONHAND      DISPLAY4 COST
  177.  
  178. DISPLAY5 PRICE       DISPLAY6             DISPLAY7
  179.  
  180. DISPLAY8             DISPLAY9             FLDDATA1   7  FLDFILE1 PARTNO
  181.  
  182. FLDDATA2   8  FLDFILE2 PART        FLDDATA3   9  FLDFILE3 PRICE
  183.  
  184.  
  185. Comments:  Record 1 in TABLE sets up a TABLE LOOKUP SYSTEM for hot-key
  186. ALT-1.  The file and index to be used both are named PART.  If the
  187. prompt field is filled in, WAMPUM will prompt the user for whatever you
  188. say.  This obviously must match the index selected.  If PROMPT is left
  189. blank, the entire table will be displayed without prompting the user.
  190. The field names in DISPLAY1 thru DISPLAY9 tell WAMPUM which fields from
  191. the PART data base to display for the user.  If all of these are left
  192. blank, then every field in the data base will be displayed in the field
  193. order specified when the file was created.  FLDDATA1 through 9 tell
  194. WAMPUM the numbers of the fields in the PRIMARY data base to be
  195. calculated.  FLDFILE1 thru 9 tell WAMPUM what data from the PART file
  196. is to be stuffed into the FLDDATA elements specified.  In this record,
  197. we are telling WAMPUM to stuff FLDDATA[7] with the PARTNO of the record
  198. chosen from the table, FLDDATA[8] is to be stuffed with the PART name,
  199. and FLDDATA[9] is to be stuffed with the PRICE of the item.
  200.  
  201.  
  202. Records 2 and 3 do the same thing for the second and third part entries
  203. in the ORDER data entry form.
  204.  
  205.  
  206. Record No.      9
  207.  
  208. FILE: CUSTOMER              INDEX: CUSTOMER
  209.  
  210. PROMPT Enter customer's last name:               DISPLAY1
  211.  
  212. DISPLAY2          DISPLAY3             DISPLAY4
  213.  
  214. DISPLAY5          DISPLAY6             DISPLAY7
  215.  
  216. DISPLAY8          DISPLAY9             FLDDATA1   1  FLDFILE1 CUSTOMER
  217.  
  218. FLDDATA2   2      FLDFILE2 ADDRESS     FLDDATA3   3  FLDFILE3 CITY
  219.  
  220. FLDDATA4   4      FLDFILE4 STATE       FLDDATA5   5  FLDFILE5 ZIP
  221.  
  222.  
  223. Comments:  In record 9 we are setting up the CUSTOMER lookup table and
  224. assigning it to ALT-9 hot key.  Here we have left all of the DISPLAY
  225. fields blank which means ALL FIELDS from the CUSTOMER table will be
  226. displayed.  Once the user selects a customer, FLDDATA[1] will be
  227. stuffed with the CUSTOMER name, FLDDATA[2] with the ADDRESS, etc.
  228.  
  229.  
  230. In closing, the beauty of all this (once you get the hang of it) is
  231. that we are only manipulating garden-variety WAMPUM data bases.  In
  232. short, true to the pure relational model, WAMPUM is designed around its
  233. own data base files.  And you can design EXTREMELY powerful applications!
  234.  
  235. If there is not room in a particular field to do what you need to do,
  236. then increase the field length by changing the file structure.  You can
  237. do this with the UNIQUE.DBF file also.  Do NOT change the field type!
  238. Although in computing the UNIQUE key, you COULD change it to a
  239. character string using the STR() function explained in the
  240. documentation.  For example, if you wanted to assign a project number
  241. in a character field of your primary data base and the format of these
  242. numbers should be a two-digit year, then a hyphen, then a five digit
  243. unique number, here is the computation you would use:
  244.  
  245.      SUBSTR(DTOC(DATE(),7,2)+"-"+STR(UNIQUE,5)
  246.  
  247. In English, this says extract the SUBSTRING of today's date beginning
  248. at position 7 for 2 places, then add a hyphen, then convert the UNIQUE
  249. number field to a 5 character string.
  250.  
  251. e beginning
  252. at position 7 for 2 places, then add a hyphen, then con